@extends('layouts.public')

@section('head')
    <link rel="stylesheet" href="{{cdn('js/plugins/webuploader/single.css')}}">
    <style>
        .items{
            margin-bottom:15px;
        }
    </style>
@endsection

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li><a href="{{route('admin.customer.customers')}}">客服列表</a></li>
                        <li @if(!isset($user))class="active"@endif><a href="{{route('admin.customer.customers.add')}}">新增</a></li>
                        @if(isset($user))
                            <li class="active"><a href="#">编辑</a></li>
                        @endif
                    </ul>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="{{route('admin.customer.customers.save')}}" method="post" class="form-horizontal ajaxForm">
                            <input type="hidden" name="id" value="{{$user->id or 0}}"/>
                           
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客服名称</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" required name="username" @if(isset($user)) value="{{$user->username or ''}}"placeholder="请填写客服姓名" @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">客服昵称</label>
                                <div class="col-sm-3">
                                    <input type="text" required class="form-control" name="nickname" @if(isset($user)) value="{{$user->nickname or ''}}"placeholder="请填写客服昵称" @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">微信号</label>
                                <div class="col-sm-3">
                                    <input type="text" required class="form-control" name="wx"  @if(isset($user)) value="{{$user->wx or ''}}"placeholder="请填写微信号" @endif autocomplete="off"/>
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-sm-2 control-label">微信二维码</label>
                                <div class="col-sm-10" id="imgupload">
                                    <div id="filePicker">选择图片</div>
                                    @if(isset($user) && $user->qrcode != '')

                                        <div class="img-div">
                                            <img src="{{get_file_url($user['qrcode'])}}"/>
                                            <span class="cancel">×</span>
                                        </div>

                                    @endif
                                    <input type="hidden" name="qrcode"  required id="qrcode" value="{{$user->qrcode or ''}}"/>
                                    <input type="hidden" name="file_id" id="file_id" value="0"/>
                                </div>

                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <button class="btn btn-white" type="button" id="backBtn">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script src="{{cdn('js/plugins/ueditor/ueditor.config.js')}}"></script>
    <script src="{{cdn('js/plugins/ueditor/ueditor.all.min.js')}}"></script>
    <script src="{{cdn('js/plugins/ueditor/lang/zh-cn/zh-cn.js')}}"></script>
    <script src="{{cdn('js/plugins/webuploader/webuploader.nolog.min.js')}}"></script>
    <script src="{{cdn('js/plugins/webuploader/webuploader_public.js')}}"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            singleUpload({
                _token: '{{csrf_token()}}',
                type_key: 'FT_ARTICLE_IMG',
                item_id: '{{$user->id or 0}}',
                pick: 'filePicker',
                boxid: 'imgupload',
                file_path: 'qrcode',
                file_id: 'file_id',
                multi: true,
                maximg: 3
            });
            $('#imgupload').find('.img-div>span').click(function () {
                sUploadDel($(this), 'qrcode');
            });
        });
    </script>
@endsection
